<template>
	<view class="content">
		<custom-tarbar :selected="3"></custom-tarbar>
		<view class="discover ">

			<!-- ======================================background-image:url(https://ossweb-img.qq.com/images/lol/web201310/skin/big10009.jpg.jpg);==== -->


			<view class="cu-card dynamic" :class="isCard?'no-card':''" v-for="(item,index) in data" :key="index" style="background-color: #d9cbcb;"
				@tap="toDetail(item.state.title)">
				<view class="cu-item shadow">
					<view class="cu-list menu-avatar">
						<view class="cu-item">
							<view class="cu-avatar round lg" :style="item.userimg"></view>
							<view class="content flex-sub">
								<view>{{item.state.publisher}}</view>
							</view>
						</view>
					</view>
					<view class="text-content">
						{{item.state.title}}
					</view>


					<view class="grid flex-sub padding-lr " :class="!isCard?'col-3 grid-square':'col-1'"
					style="margin: auto;">
						<!-- <view class="bg-img" :class="isCard?'':'only-img'" -->
						<view class="bg-img" :class="!isCard?'':'only-img'"
							:style="image.imgurl"
							v-for="(image,index) in item.images" :key="index">
						</view>
					</view>
				</view>


			</view>
		</view>





		<!-- ========================================== -->
		<down-block></down-block>

	</view>
	</view>
</template>

<script>
	import customTarbar from '@/wxcomponents/custom-tarbar/custom-tarbar.vue';
	import downBlock from '../../components/down_block.vue'
	export default {
		components: {
			'custom-tarbar': customTarbar,
			downBlock
		},
		data() {
			return {
				isCard: false,
				data: {}
			};
		},
		onShow() {
			this.getDetail()
		},
		methods: {
			toDetail(stateTitle) {
				uni.navigateTo({
					url: '../discuss/discuss?StateDetail='+stateTitle
				})
			},
			async getDetail() {
				const baseurl = getApp().globalData.BASE_URL
				const inner = this
				uni.request({
					url: baseurl + "/state/GetStateInfo",
					success(res) {
						inner.data = res.data
						let list = res.data
						for (var i = 0; i < list.length; i++) {
							list[i].userimg = "background-image:url(" + baseurl+list[i].userimg + ");"
							for (var j = 0; j < list[i].images.length; j++) {
								if( list[i].images[j].imgurl.indexOf("http")==-1){
									//本地图片
									list[i].images[j].imgurl=baseurl+list[i].images[j].imgurl
								}
								list[i].images[j].imgurl = "background-image:url(" + list[i].images[j].imgurl +
									");"
							}
						}
						res.data = list
					}
				})
			}
		},
	};
</script>

<style lang="scss">

</style>
